<?php
/**
 *  * 系统-受国家计算机软件著作权保护 - !
 * =========================================================
 * Copy right 2018-2025 成都海之心科技有限公司, 保留所有权利。
 * ----------------------------------------------
 * 官方网址: http://www.ohyu.cn
 * 这不是一个自由软件！在未得到官方有效许可的前提下禁止对程序代码进行修改和使用。
 * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
 * =========================================================
 * User: ohyueo
 * Date: 2024/5/30
 * Time: 14:17
 */
namespace app\install\controller;
use think\facade\Db;

/**
 * 安装模块 - 导入数据库
 * Class Index
 * @package app\install\controller
 */
class OperSql extends ApiBase
{   
    //初始化传值给prefix
    public function __construct($prefix)
    {
        $this->prefix = $prefix;
    }
    //导入数据库
    public function importsql()
    {   
        //开启事务 
        Db::startTrans();
        try {
            $this->importadmin();
            $this->importadminactionlog();
            $this->importadminlogin();
            $this->importadminpermission();
            $this->importadminrole();
            $this->importadminrolepermission();
            $this->importadminuserrole();
            $this->importuserlist();
            $this->importuserlogin();
            $this->importuserinfo();
            $this->importusertoken();
            $this->importzongheimg();
            $this->importnotilist();
            $this->importwebtext();
            $this->importmapregprovince();
            $this->importaccesstoken();
            $this->importbrowse();
            $this->importworkertexter();
            $this->importdevelocurdlist();
            $this->importdevelocurdtable();
            $this->importaddcity();
            $this->importsystemwork();
            $this->importcallcalllist();
            $this->importspeefiles();
            $this->importauthdata();//导入权限
            $this->importtooldata();//导入工具
            $this->importusermoneylog();//导入user_moneylog
            $this->importuserintegral();//导入user_integrallog
            $this->importmallpaypayorder();//导入user_loginlog
            $this->importmallpayincome();//导入user_logintoken
            $this->importmallpayrefund();//导入user_loginlog
            $this->importohyueoimglist();//导入importohyueoimglist
            //importautomessage,importautosysmessage,importautomessagetext
            $this->importautomessage();//导入importautomessage
            $this->importautosysmessage();//导入importautosysmessage
            $this->importautomessagetext();//导入importautomessagetext
            $code=1;
            $msg='导入成功';
            // 提交事务
            Db::commit();
        } catch (\Exception $e) {
            // 回滚事务
            Db::rollback();
            $code=0;
            $error=$e->getMessage();
            $msg='导入失败'.$error;
            $rearr=[];
        }
        return ['code'=>$code,'msg'=>$msg];
    }
    //导入admin表
    public function importadmin()
    {
        $sql = "CREATE TABLE IF NOT EXISTS `".$this->prefix."admin` (
            `id` int(11) NOT NULL AUTO_INCREMENT,
            `username` varchar(12) NOT NULL,
            `name` varchar(255) DEFAULT NULL,
            `password` varchar(35) NOT NULL,
            `gid` int(11) NOT NULL DEFAULT '1',
            `addtime` int(11) NOT NULL,
            `lastlogin` int(11) NOT NULL,
            `status` int(1) NOT NULL DEFAULT '1',
            `text` varchar(255) DEFAULT NULL COMMENT '',
            `merid` int(11) NOT NULL DEFAULT '0',
            PRIMARY KEY (`id`)
          ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;";
        Db::execute($sql);
        $sql = "INSERT INTO `".$this->prefix."admin` VALUES (1,'admin','管理员','22666d978f0b0b67d420d416ae7ec363',1,0,0,1,NULL,0);";
        Db::execute($sql);
    }
    //导入admin_action_log表
    public function importadminactionlog()
    {
        $sql = "CREATE TABLE IF NOT EXISTS `".$this->prefix."admin_action_log` (
            `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
            `user` varchar(50) NOT NULL,
            `text` varchar(255) DEFAULT NULL,
            `addtime` char(11) DEFAULT NULL,
            `ip` varchar(55) DEFAULT NULL COMMENT '',
            `merid` int(11) NOT NULL DEFAULT '0',
            PRIMARY KEY (`id`)
          ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='';";
        Db::execute($sql);
    }
    //导入admin_login表
    public function importadminlogin()
    {
        $sql = "CREATE TABLE IF NOT EXISTS `".$this->prefix."admin_login` (
            `id` int(11) NOT NULL AUTO_INCREMENT,
            `username` varchar(16) NOT NULL,
            `logintime` int(11) NOT NULL DEFAULT '0',
            `loginip` varchar(255) NOT NULL,
            `status` int(11) DEFAULT '1',
            `info` varchar(255) DEFAULT NULL,
            `token` varchar(255) DEFAULT NULL,
            `merid` int(11) NOT NULL DEFAULT '0',
            PRIMARY KEY (`id`)
          ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;";
        Db::execute($sql);
    }
    //导入admin_permission表
    public function importadminpermission()
    {
        $sql = "CREATE TABLE IF NOT EXISTS `".$this->prefix."admin_permission` (
            `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
            `name` varchar(50) NOT NULL,
            `controller` varchar(50) DEFAULT NULL,
            `action` varchar(255) DEFAULT NULL,
            `parent_id` int(10) unsigned NOT NULL DEFAULT '0',
            `is_nav` tinyint(1) NOT NULL DEFAULT '0',
            `icon` varchar(30) DEFAULT NULL,
            `p_id` int(3) DEFAULT '0',
            `type` int(3) DEFAULT '1',
            `addons` varchar(255) DEFAULT NULL,
            `merid` int(11) NOT NULL DEFAULT '0',
            PRIMARY KEY (`id`)
          ) ENGINE=MyISAM AUTO_INCREMENT=40 DEFAULT CHARSET=utf8;";
        Db::execute($sql);
    }
    //导入admin_role表
    public function importadminrole()
    {
        $sql = "CREATE TABLE IF NOT EXISTS `".$this->prefix."admin_role` (
            `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
            `name` varchar(50) NOT NULL COMMENT '',
            `text` varchar(255) DEFAULT NULL COMMENT '',
            `merid` int(11) NOT NULL DEFAULT '0',
            PRIMARY KEY (`id`)
          ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='';";
          
        Db::execute($sql);
        $sql = "INSERT INTO `".$this->prefix."admin_role` VALUES (1,'超级管理员','管理员',0);";
        Db::execute($sql);
    }
    //导入admin_role_permission表
    public function importadminrolepermission()
    {
        $sql = "CREATE TABLE IF NOT EXISTS `".$this->prefix."admin_role_permission` (
            `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
            `role_id` int(10) unsigned NOT NULL COMMENT '',
            `permission_id` text COMMENT '',
            `merid` int(11) NOT NULL DEFAULT '0',
            PRIMARY KEY (`id`)
          ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='角色权限关联表';";
        Db::execute($sql);
        //插入1-66的权限
        $sql = "INSERT INTO `".$this->prefix."admin_role_permission` VALUES (1,1,'1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66',0);";
        Db::execute($sql);
    }
    //导入admin_user_role表
    public function importadminuserrole()
    {
        $sql = "CREATE TABLE IF NOT EXISTS `".$this->prefix."admin_user_role` (
            `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
            `admin_id` int(10) unsigned NOT NULL,
            `role_id` int(11) NOT NULL,
            `merid` int(11) NOT NULL DEFAULT '0',
            PRIMARY KEY (`id`)
          ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='';";
        Db::execute($sql);
        $sql = "INSERT INTO `".$this->prefix."admin_user_role` VALUES (1,1,1,0);";
        Db::execute($sql);
    }
    //导入user_list表
    public function importuserlist()
    {
        $sql = "CREATE TABLE IF NOT EXISTS `".$this->prefix."user_list` (
            `id` int(11) NOT NULL AUTO_INCREMENT,
            `nick` varchar(55) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '',
            `headimg` varchar(155) DEFAULT NULL COMMENT '',
            `money` decimal(10,2) DEFAULT '0.00' COMMENT '',
            `price` decimal(10,2) DEFAULT '0.00' COMMENT '',
            `integral` int(11) DEFAULT '0' COMMENT '',
            `status` int(3) DEFAULT '1' COMMENT '',
            `openid` varchar(155) DEFAULT NULL,
            `xcx_openid` varchar(255) DEFAULT NULL COMMENT '',
            `unionid` varchar(255) DEFAULT NULL COMMENT '',
            `merid` int(11) NOT NULL DEFAULT '0',
            PRIMARY KEY (`id`)
          ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='';";
        Db::execute($sql);
    }
    //导入user_login表
    public function importuserlogin()
    {
        $sql = "CREATE TABLE IF NOT EXISTS `".$this->prefix."user_login` (
            `id` int(11) NOT NULL AUTO_INCREMENT,
            `uid` int(11) DEFAULT '0' COMMENT '',
            `username` varchar(55) DEFAULT NULL COMMENT '',
            `password` varchar(255) DEFAULT NULL COMMENT '',
            `reg_time` datetime COMMENT '',
            `rece_login_time` datetime COMMENT '',
            `mobile` varchar(15) DEFAULT NULL COMMENT '',
            `email` varchar(35) DEFAULT NULL COMMENT '',
            `reg_ip` varchar(55) DEFAULT NULL COMMENT '',
            `session_key` varchar(155) DEFAULT NULL,
            `reg_city` varchar(255) DEFAULT NULL COMMENT '',
            `reg_province` varchar(255) DEFAULT NULL COMMENT '',
            `merid` int(11) NOT NULL DEFAULT '0',
            PRIMARY KEY (`id`)
          ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;";
        Db::execute($sql);
    }
    //导入user_info表
    public function importuserinfo()
    {
        $sql = "CREATE TABLE IF NOT EXISTS `".$this->prefix."user_info` (
            `id` int(11) NOT NULL AUTO_INCREMENT,
            `user_id` int(11) DEFAULT '0' COMMENT '',
            `timo` decimal(10,2) DEFAULT '0.00' COMMENT '',
            `name` varchar(155) DEFAULT NULL COMMENT '',
            `mobile` varchar(25) DEFAULT NULL COMMENT '',
            `merid` int(11) NOT NULL DEFAULT '0',
            PRIMARY KEY (`id`)
          ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='';";
        Db::execute($sql);
    }
    //导入user_token表
    public function importusertoken()
    {
        $sql = "CREATE TABLE IF NOT EXISTS `".$this->prefix."user_token` (
            `id` int(11) NOT NULL AUTO_INCREMENT,
            `user_id` int(11) DEFAULT '0',
            `token` varchar(65) DEFAULT NULL,
            `update_time` datetime NOT NULL COMMENT '',
            `merid` int(11) NOT NULL DEFAULT '0',
            PRIMARY KEY (`id`)
          ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='';";
        Db::execute($sql);
    }
    //导入zonghe_img表
    public function importzongheimg()
    {
        $sql = "CREATE TABLE IF NOT EXISTS `".$this->prefix."zonghe_img` (
            `id` int(11) NOT NULL AUTO_INCREMENT,
            `title` varchar(55) DEFAULT NULL COMMENT '',
            `img` varchar(155) DEFAULT NULL COMMENT '',
            `type` int(3) DEFAULT '1' COMMENT '',
            `url` varchar(255) DEFAULT NULL COMMENT '',
            `style` int(3) DEFAULT '1' COMMENT '',
            `status` int(3) DEFAULT '1' COMMENT '',
            `paiid` int(11) DEFAULT '0' COMMENT '',
            `merid` int(11) NOT NULL DEFAULT '0',
            PRIMARY KEY (`id`)
          ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;";
        Db::execute($sql);
    }
    //导入noti_list表
    public function importnotilist()
    {
        $sql = "CREATE TABLE IF NOT EXISTS `".$this->prefix."noti_list` (
            `id` int(11) NOT NULL AUTO_INCREMENT,
            `title` varchar(255) DEFAULT NULL COMMENT '',
            `text` text COMMENT '',
            `addtime` datetime DEFAULT NULL COMMENT '',
            `pv` int(11) DEFAULT '0' COMMENT '',
            `merid` int(11) NOT NULL DEFAULT '0',
            PRIMARY KEY (`id`)
          ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='';";
        Db::execute($sql);
    }
    //导入web_text表
    public function importwebtext()
    {
        $sql = "CREATE TABLE IF NOT EXISTS `".$this->prefix."web_text` (
            `id` int(11) NOT NULL AUTO_INCREMENT,
            `title` varchar(255) NOT NULL,
            `texter` text NOT NULL,
            `addtime` datetime NOT NULL,
            `merid` int(11) NOT NULL DEFAULT '0',
            PRIMARY KEY (`id`)
          ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;";
        Db::execute($sql);
        $sql = "INSERT INTO `".$this->prefix."web_text` VALUES (1,'平台协议','平台协议','2022-05-17 00:00:00',0),(2,'隐私政策','隐私政策','2022-05-17 00:00:00',0),(3,'联系我们','联系我们','2022-05-17 00:00:00',0);";
        Db::execute($sql);
    }
    //导入map_regprovince表
    public function importmapregprovince()
    {
        $sql = "CREATE TABLE IF NOT EXISTS `".$this->prefix."map_regprovince` (
            `id` int(11) NOT NULL AUTO_INCREMENT,
            `province` varchar(255) DEFAULT NULL COMMENT '省份',
            `name` varchar(255) DEFAULT NULL,
            `value` int(11) DEFAULT '0',
            `merid` int(11) NOT NULL DEFAULT '0',
            PRIMARY KEY (`id`)
          ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='注册省份';";
        Db::execute($sql);
    }
    //导入access_token表
    public function importaccesstoken()
    {
        $sql = "CREATE TABLE IF NOT EXISTS `".$this->prefix."access_token` (
            `id` int(11) NOT NULL AUTO_INCREMENT,
            `access_token` varchar(600) NOT NULL DEFAULT '' COMMENT '',
            `expires_time` varchar(64) DEFAULT NULL COMMENT '',
            `ticket` varchar(600) NOT NULL DEFAULT '' COMMENT '',
            `ticket_expires_time` varchar(64) DEFAULT NULL COMMENT '',
            `merid` int(11) NOT NULL DEFAULT '0',
            PRIMARY KEY (`id`)
          ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='';";
        Db::execute($sql);
    }
    //导入browse表
    public function importbrowse()
    {
        $sql = "CREATE TABLE IF NOT EXISTS `".$this->prefix."browse` (
            `id` int(11) NOT NULL AUTO_INCREMENT,
            `ip` varchar(55) DEFAULT NULL,
            `uid` int(11) DEFAULT '0',
            `no` int(11) DEFAULT '0',
            `addtime` datetime DEFAULT NULL,
            `merid` int(11) NOT NULL DEFAULT '0',
            PRIMARY KEY (`id`)
          ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='浏览量';";
        Db::execute($sql);
    }
    //导入worker_texter表
    public function importworkertexter()
    {
        $sql = "CREATE TABLE IF NOT EXISTS `".$this->prefix."worker_texter` (
            `id` int(11) NOT NULL AUTO_INCREMENT,
            `title` varchar(255) DEFAULT NULL COMMENT '',
            `img` varchar(155) DEFAULT NULL COMMENT '',
            `texter` text COMMENT '',
            `pv` int(11) DEFAULT '0' COMMENT '',
            `addtime` datetime DEFAULT NULL COMMENT '',
            `status` int(3) DEFAULT '1' COMMENT '',
            `istui` int(3) DEFAULT '0' COMMENT '',
            `merid` int(11) NOT NULL DEFAULT '0',
            PRIMARY KEY (`id`)
          ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='';";
        Db::execute($sql);
    }
    //导入develo_curdlist表
    public function importdevelocurdlist()
    {
        $sql = "CREATE TABLE IF NOT EXISTS `".$this->prefix."develo_curdlist` (
            `id` int(11) NOT NULL AUTO_INCREMENT,
            `title` varchar(255) DEFAULT NULL COMMENT 'curd列表标题',
            `navid` int(11) unsigned DEFAULT '0' COMMENT '顶级菜单id',
            `model` varchar(255) DEFAULT NULL COMMENT '模块名称',
            `action` varchar(255) DEFAULT NULL COMMENT '方法名称',
            `table` varchar(255) DEFAULT NULL COMMENT '数据表名称',
            `beizhu` varchar(255) DEFAULT NULL COMMENT '表备注',
            `addtime` datetime DEFAULT NULL COMMENT '添加时间',
            `role_type` int(3) DEFAULT '1' COMMENT '生成权限  1是  2否',
            `daochu` int(3) DEFAULT '1' COMMENT '导出  1是  2否',
            PRIMARY KEY (`id`)
          ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='curd列表';";
        Db::execute($sql);
    }
    //导入develo_curdtable表
    public function importdevelocurdtable()
    {
        $sql = "CREATE TABLE IF NOT EXISTS `".$this->prefix."develo_curdtable` (
            `id` int(11) NOT NULL AUTO_INCREMENT,
            `listid` int(11) DEFAULT '0' COMMENT '列表id',
            `name` varchar(155) DEFAULT NULL COMMENT '数据表名称',
            `type` int(3) DEFAULT '1' COMMENT '字段类型  1 varchar  2int',
            `length` varchar(55) DEFAULT NULL COMMENT '字段长度',
            `default` varchar(255) DEFAULT NULL COMMENT '默认值',
            `beizhu` varchar(255) DEFAULT NULL COMMENT '备注',
            `style` int(3) DEFAULT '1' COMMENT '字段类型  1 文本框  2单选框',
            `val` varchar(125) DEFAULT NULL COMMENT '表单值，多个用,隔开',
            `search` int(3) DEFAULT '0' COMMENT '搜索该字段  0否  1是',
            PRIMARY KEY (`id`)
          ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='curd的数据表';";
        Db::execute($sql);
    }
    //导入addcity表
    public function importaddcity()
    {
        $sql = "CREATE TABLE IF NOT EXISTS `".$this->prefix."addcity` (
            `id` int(11) NOT NULL AUTO_INCREMENT,
            `pid` int(11) DEFAULT '0' COMMENT '',
            `val` varchar(255) DEFAULT NULL COMMENT '',
            `type` int(3) DEFAULT '0' COMMENT '',
            `citycode` varchar(85) DEFAULT NULL COMMENT '',
            `merid` int(11) NOT NULL DEFAULT '0',
            PRIMARY KEY (`id`)
          ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COMMENT='';";
        Db::execute($sql);
    }
    //导入system_work表
    public function importsystemwork()
    {
        $sql = "CREATE TABLE `".$this->prefix."system_work` (
            `id` int(11) NOT NULL AUTO_INCREMENT,
            `event` varchar(155) DEFAULT NULL,
            `orderid` int(11) DEFAULT '0' COMMENT '订单id',
            `is_push` int(3) DEFAULT '0' COMMENT '是否推送 0否 1是',
            `addtime` datetime DEFAULT NULL COMMENT '添加时间',
            `updatetime` datetime DEFAULT NULL COMMENT '更新时间',
            `otherid` int(11) DEFAULT '0' COMMENT '其他id',
            `no` varchar(25) DEFAULT '0' COMMENT '编号',
            `which` varchar(25) DEFAULT NULL COMMENT '叫号的号码',
            `status` int(3) DEFAULT '1' COMMENT '状态 1预约成功 2正在叫号 3已过号 4开始办理 5取消预约 6预约完成',
            `gui` varchar(25) DEFAULT NULL COMMENT '柜台名称',
            `bankid` int(11) DEFAULT '0' COMMENT '银行id 区域id 给哪个大屏下发通知',
            `merid` int(11) NOT NULL DEFAULT '0',
            PRIMARY KEY (`id`)
          ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;";
        Db::execute($sql);
    }
    //导入call_calllist表
    public function importcallcalllist()
    {
        $sql = "CREATE TABLE `".$this->prefix."call_calllist` (
            `id` int(11) NOT NULL AUTO_INCREMENT,
            `title` varchar(255) DEFAULT 'NULL' COMMENT '机构名称',
            `status` int(3) DEFAULT '1' COMMENT '状态',
            `paiid` int(11) DEFAULT '0' COMMENT '排序ID',
            `hechengtype` int(3) DEFAULT '1' COMMENT '合成方式  1阿里云  2本地',
            `anzhuo` varchar(255) DEFAULT NULL COMMENT '安卓',
            `pc` varchar(255) DEFAULT NULL COMMENT 'pc电脑',
            `merid` int(11) NOT NULL DEFAULT '0',
            PRIMARY KEY (`id`)
          ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;";
        Db::execute($sql);
    }
    //导入speefiles表
    public function importspeefiles()
    {
        $sql = "CREATE TABLE `".$this->prefix."speefiles` (
            `id` int(11) NOT NULL AUTO_INCREMENT,
            `title` varchar(255) DEFAULT NULL COMMENT '语音文字',
            `content` varchar(255) DEFAULT NULL COMMENT '语音内容',
            `file` varchar(255) DEFAULT NULL COMMENT '文件路径',
            `merid` int(11) NOT NULL DEFAULT '0',
            PRIMARY KEY (`id`)
          ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='语音生成的文件';";
        Db::execute($sql);
    }

    //导入权限sql
    public function importauthdata(){
      $sql="INSERT INTO `".$this->prefix."admin_permission` VALUES
      (1,'主页',NULL,NULL,0,1,'layui-icon-home',1,1,NULL,0),
      (2,'应用管理',NULL,NULL,0,1,'layui-icon-template-1',2,1,NULL,0),
      (3,'权限管理',NULL,NULL,0,1,'layui-icon-auz',4,1,NULL,0),
      (4,'管理员列表','Admin','userlist',3,1,NULL,0,1,NULL,0),
      (5,'角色列表','Admin','rolelist',3,1,NULL,0,1,NULL,0),
      (6,'编辑','Admin/userlist','edituser',4,0,NULL,0,1,NULL,0),
      (7,'添加','Admin/userlist','adduser',4,0,NULL,0,1,NULL,0),
      (8,'删除','Admin/userlist','deluser',4,0,NULL,0,1,NULL,0),
      (9,'编辑','Admin/rolelist','editrole',5,0,NULL,0,1,NULL,0),
      (10,'添加','Admin/rolelist','addrole',5,0,NULL,0,1,NULL,0),
      (11,'删除','Admin/rolelist','delrole',5,0,NULL,0,1,NULL,0),
      (12,'轮播图','Zong','zhimg',2,1,NULL,0,1,NULL,0),
      (13,'添加','Zong/zhimg','addimg',12,0,NULL,0,1,NULL,0),
      (14,'删除','Zong/zhimg','delimg',12,0,NULL,0,1,NULL,0),
      (15,'修改','Zong/zhimg','editimg',12,0,NULL,0,1,NULL,0),
      (16,'管理员日志','Admin','actionlog',3,1,NULL,0,1,NULL,0),
      (17,'控制台','Home','console',1,1,NULL,0,1,NULL,0),
      (18,'设置',NULL,NULL,0,1,'layui-icon-set',5,1,NULL,0),
      (19,'接口设置','','',18,2,NULL,0,1,NULL,0),
      (20,'短信设置','Set','smssite',19,1,NULL,0,1,NULL,0),
      (21,'地图设置','Set','mapsite',19,1,NULL,0,1,NULL,0),
      (22,'系统设置','',NULL,18,2,NULL,0,1,NULL,0),
      (23,'前端设置','Set','appsite',22,1,NULL,0,1,NULL,0),
      (24,'用户管理','','',0,1,'layui-icon-user',4,1,NULL,0),
      (25,'用户列表','User','userlist',24,1,NULL,0,1,NULL,0),
      (26,'添加','User/userlist','add',25,0,NULL,0,1,NULL,0),
      (27,'编辑','User/userlist','edit',25,0,NULL,0,1,NULL,0),
      (28,'黑名单','User','userlist_hei',24,1,NULL,0,1,NULL,0),
      (29,'黑名单','User/userlist','setStatus',25,0,NULL,0,1,NULL,0),
      (30,'黑名单','User/userlist_hei','setStatus',28,0,NULL,0,1,NULL,0),
      (31,'详情','User/userlist_hei','userinfo',28,0,NULL,0,1,NULL,0),
      (32,'详情','User/userlist','userinfo',25,0,NULL,0,1,NULL,0),
      (33,'删除','User/userlist','del',25,0,NULL,0,1,NULL,0),
      (34,'系统公告','Zong','announce',2,1,NULL,0,1,NULL,0),
      (35,'添加','Zong/announce','addannounce',34,0,NULL,0,1,NULL,0),
      (36,'修改','Zong/announce','editannounce',34,0,NULL,0,1,NULL,0),
      (37,'删除','Zong/announce','delannounce',34,0,NULL,0,1,NULL,0),
      (38,'系统文章','Wen','sydex',2,1,NULL,0,1,NULL,0),
      (39,'修改','Wen/sydex','editsywen',38,0,NULL,0,1,NULL,0),
      (40,'开发工具','','',0,1,'layui-icon-util',3,1,'',0),
      (41,'顶级栏目生成','Autocurd','topnav',40,1,'',0,1,'',0),
      (42,'添加','Autocurd/topnav','addtopnav',41,0,'',0,1,'',0),
      (43,'修改','Autocurd/topnav','edittopnav',41,0,'',0,1,'',0),
      (44,'修改','Autocurd/topnav','codetopnav',41,0,'',0,1,'',0),
      (45,'删除','Autocurd/topnav','deltopnav',41,0,'',0,1,'',0),
      (46,'CURD生成列表','Autocurd','curdlist',40,1,'',0,1,'',0),
      (47,'添加CURD','Autocurd/curdlist','addcurd',46,0,'',0,1,'',0),
      (48,'修改CURD','Autocurd/curdlist','editcurd',46,0,'',0,1,'',0),
      (49,'删除CURD','Autocurd/curdlist','delcurd',46,0,'',0,1,'',0),
      (50,'文章资讯','Wen','index',2,1,NULL,0,1,NULL,0),
      (51,'添加','Wen/index','addwen',50,0,NULL,0,1,NULL,0),
      (52,'修改','Wen/index','editwen',50,0,NULL,0,1,NULL,0),
      (53,'删除','Wen/index','delwen',50,0,NULL,0,1,NULL,0),
      (54,'微信设置','Set','wxsite',22,1,NULL,0,1,NULL,0),
      (55,'财务管理','Pay',NULL,0,1,'layui-icon-rmb',3,1,'',0),
      (56,'支付记录','pay','payorder',55,1,'',0,1,'',0),
      (57,'删除','pay/payorder','delpayorder',56,0,'',0,1,'',0),
      (58,'收入记录','pay','income',55,1,'',0,1,'',0),
      (59,'删除','pay/income','delincome',58,0,'',0,1,'',0),
      (60,'退款记录','pay','refund',55,1,'',0,1,'',0),
      (61,'删除','pay/refund','delrefund',60,0,'',0,1,'',0),
      (62,'积分记录','Pay','integrallog',55,1,'',0,1,'',0),
      (63,'删除','Pay/integrallog','delintegrallog',62,0,'',0,1,'',0),
      (64,'资金记录','Pay','usermoneylog',55,1,'',0,1,'',0),
      (65,'删除','Pay/usermoneylog','delmoneylog',64,0,'',0,1,'',0),
      (66,'积分/金额','User/userlist','zjmoney',25,0,NULL,0,1,NULL,0);";
      Db::execute($sql);
    }

    //导入工具sql
    public function importtooldata(){
      $sql = "CREATE TABLE IF NOT EXISTS `ohyueo_develo_curdlist` (
          `id` int(11) NOT NULL AUTO_INCREMENT,
          `title` varchar(255) DEFAULT NULL COMMENT 'curd列表标题',
          `navid` int(11) unsigned DEFAULT '0' COMMENT '顶级菜单id',
          `model` varchar(255) DEFAULT NULL COMMENT '模块名称',
          `action` varchar(255) DEFAULT NULL COMMENT '方法名称',
          `table` varchar(255) DEFAULT NULL COMMENT '数据表名称',
          `beizhu` varchar(255) DEFAULT NULL COMMENT '表备注',
          `addtime` datetime DEFAULT NULL COMMENT '添加时间',
          `role_type` int(3) DEFAULT '1' COMMENT '生成权限  1是  2否',
          `daochu` int(3) DEFAULT '1' COMMENT '导出  1是  2否',
          PRIMARY KEY (`id`)
        ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='curd列表';";
      Db::execute($sql);
      $sql = "CREATE TABLE IF NOT EXISTS `ohyueo_develo_curdtable` (
          `id` int(11) NOT NULL AUTO_INCREMENT,
          `listid` int(11) DEFAULT '0' COMMENT '列表id',
          `name` varchar(155) DEFAULT NULL COMMENT '数据表名称',
          `type` int(3) DEFAULT '1' COMMENT '字段类型  1 varchar  2int',
          `length` varchar(55) DEFAULT NULL COMMENT '字段长度',
          `default` varchar(255) DEFAULT NULL COMMENT '默认值',
          `beizhu` varchar(255) DEFAULT NULL COMMENT '备注',
          `style` int(3) DEFAULT '1' COMMENT '字段类型  1 文本框  2单选框',
          `val` varchar(125) DEFAULT NULL COMMENT '表单值，多个用,隔开',
          `search` int(3) DEFAULT '0' COMMENT '搜索该字段  0否  1是',
          PRIMARY KEY (`id`)
        ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='curd的数据表';";
      Db::execute($sql);
    }

      //导入user_moneylog表
    public function importusermoneylog()
    {
        $sql = "CREATE TABLE IF NOT EXISTS `".$this->prefix."user_moneylog` (
            `id` int(11) NOT NULL AUTO_INCREMENT,
            `user_id` int(11) DEFAULT '0',
            `money` decimal(10,2) DEFAULT '0.00',
            `giving` decimal(10,2) DEFAULT '0.00',
            `text` varchar(255) DEFAULT NULL,
            `type` int(2) DEFAULT '1',
            `mo_type` int(2) DEFAULT '1',
            `shop_id` int(11) DEFAULT '0',
            `yue` decimal(10,2) DEFAULT '0.00',
            `addtime` datetime DEFAULT NULL,
            `merid` int(11) DEFAULT '0' COMMENT '租户id',
            PRIMARY KEY (`id`)
          ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;";
        Db::execute($sql);
    }

    //导入user_integral表
    public function importuserintegral()
    {
        $sql = "CREATE TABLE IF NOT EXISTS `".$this->prefix."user_integral` (
            `id` int(11) NOT NULL AUTO_INCREMENT,
            `user_id` int(11) DEFAULT '0',
            `money` int(10) DEFAULT '0',
            `text` varchar(255) DEFAULT NULL,
            `type` int(2) DEFAULT '1',
            `mo_type` int(2) DEFAULT '1',
            `shop_id` int(11) DEFAULT '0',
            `yue` int(10) DEFAULT '0',
            `addtime` datetime DEFAULT NULL,
            `merid` int(11) DEFAULT '0' COMMENT '租户id',
            PRIMARY KEY (`id`)
          ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;";
        Db::execute($sql);
    }
    //导入pay_payorder表
    public function importmallpaypayorder()
    {
        $sql = "CREATE TABLE IF NOT EXISTS `".$this->prefix."pay_payorder` (
            `id` int(11) NOT NULL AUTO_INCREMENT,
            `orderid` int(11) DEFAULT '0' COMMENT '订单id',
            `money` decimal(10,2) DEFAULT '0.00' COMMENT '支付金额',
            `paymo` decimal(10,2) DEFAULT '0.00' COMMENT '实际支付金额',
            `addtime` datetime DEFAULT NULL COMMENT '创建时间',
            `status` int(3) DEFAULT '0' COMMENT '状态',
            `ordernum` varchar(155) DEFAULT 'NULL' COMMENT '订单号',
            `trade_no` varchar(155) DEFAULT 'NULL' COMMENT '第三方支付号',
            `uid` int(11) DEFAULT '0' COMMENT '用户',
            `paytime` datetime DEFAULT NULL COMMENT '支付时间',
            `merid` int(11) DEFAULT '0' COMMENT '租户id',
            `type` int(2) DEFAULT '1' COMMENT '付款类型 1公众号 2小程序',
            `style` int(2) DEFAULT '1' COMMENT '1商品订单',
            PRIMARY KEY (`id`)
          ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='支付记录';";
        Db::execute($sql);
    }

    //导入pay_income表
    public function importmallpayincome()
    {
        $sql = "CREATE TABLE IF NOT EXISTS `".$this->prefix."pay_income` (
            `id` int(11) NOT NULL AUTO_INCREMENT,
            `title` varchar(255) DEFAULT 'NULL' COMMENT '标题',
            `paymo` decimal(10,2) DEFAULT '0.00' COMMENT '支付金额',
            `orderid` int(11) DEFAULT '0' COMMENT '订单id',
            `uid` int(11) DEFAULT '0' COMMENT '用户',
            `addtime` datetime DEFAULT NULL COMMENT '创建时间',
            `status` int(3) DEFAULT '1' COMMENT '状态',
            `tuimo` decimal(10,2) DEFAULT '0.00' COMMENT '退款金额',
            `usertype` int(3) DEFAULT '1' COMMENT '退款人员',
            `tuitime` datetime DEFAULT NULL COMMENT '退款时间',
            `merid` int(11) DEFAULT '0' COMMENT '商户id',
            PRIMARY KEY (`id`)
          ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='收入记录';";
        Db::execute($sql);
    }

    //导入pay_refund表
    public function importmallpayrefund()
    {
        $sql = "CREATE TABLE IF NOT EXISTS `".$this->prefix."pay_refund` (
            `id` int(11) NOT NULL AUTO_INCREMENT,
            `title` varchar(255) DEFAULT 'NULL' COMMENT '标题',
            `orderid` int(11) DEFAULT '0' COMMENT '订单id',
            `uid` int(11) DEFAULT '0' COMMENT '用户',
            `paytime` datetime DEFAULT NULL COMMENT '支付时间',
            `tuitime` datetime DEFAULT NULL COMMENT '退款成功时间',
            `addtime` datetime DEFAULT NULL COMMENT '创建时间',
            `tuimsg` varchar(255) DEFAULT 'NULL' COMMENT '退款原因',
            `usertype` int(3) DEFAULT '1' COMMENT '退款人员',
            `userid` int(11) DEFAULT '0' COMMENT '人员id',
            `payid` int(11) DEFAULT '0' COMMENT '支付id',
            `tuimo` decimal(10,2) DEFAULT '0.00' COMMENT '退款金额',
            `paymo` decimal(10,2) DEFAULT '0.00' COMMENT '支付金额',
            `money` decimal(10,2) DEFAULT '0.00' COMMENT '订单金额',
            `merid` int(11) DEFAULT '0' COMMENT '商家',
            PRIMARY KEY (`id`)
          ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='退款记录';";
        Db::execute($sql);
    }

    //导入ohyueo_img_list表
    public function importohyueoimglist()
    {
        $sql = "CREATE TABLE IF NOT EXISTS `ohyueo_img_list` (
            `id` int(11) NOT NULL AUTO_INCREMENT,
            `uid` int(11) DEFAULT NULL COMMENT '用户id',
            `fid` int(11) DEFAULT NULL COMMENT '文件夹id',
            `path` text CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '图片路径',
            `addtime` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间',
            `type` int(3) DEFAULT '1' COMMENT '图片类型 1 公有， 2私有',
            `site` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '云端地址（为空为本地）',
            `state` int(3) DEFAULT '1' COMMENT '状态 1 正常 5 回收站',
            `deltime` datetime DEFAULT NULL COMMENT '放入回收站时间（超过10天后删除）',
            `remark` text CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '备注',
            PRIMARY KEY (`id`)
          ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='';";
        Db::execute($sql);
    }

    // CREATE TABLE IF NOT EXISTS `auto_message` (
    //   `id` int(11) NOT NULL AUTO_INCREMENT,
    //   `sendid` int(11) DEFAULT '0' COMMENT '发件人id',
    //   `recid` int(11) DEFAULT '0' COMMENT '收件人id',
    //   `textid` int(11) DEFAULT '0' COMMENT '消息id',
    //   `status` int(11) DEFAULT '0' COMMENT '已读1/未读0',
    //   PRIMARY KEY (`id`)
    // ) ENGINE=InnoDB AUTO_INCREMENT=47 DEFAULT CHARSET=utf8;

    //导入auto_message表
    public function importautomessage()
    {
      $sql = "CREATE TABLE IF NOT EXISTS `".$this->prefix."message` (
            `id` int(11) NOT NULL AUTO_INCREMENT,
            `sendid` int(11) DEFAULT '0' COMMENT '发件人id',
            `recid` int(11) DEFAULT '0' COMMENT '收件人id',
            `textid` int(11) DEFAULT '0' COMMENT '消息id',
            `status` int(11) DEFAULT '0' COMMENT '已读1/未读0',
            PRIMARY KEY (`id`)
          ) ENGINE=InnoDB AUTO_INCREMENT=47 DEFAULT CHARSET=utf8;";
        Db::execute($sql);
    }
    // CREATE TABLE IF NOT EXISTS `auto_message_text` (
    //   `id` int(11) NOT NULL AUTO_INCREMENT,
    //   `title` varchar(255) DEFAULT NULL COMMENT '标题',
    //   `text` text COMMENT '内容',
    //   `addtime` int(11) DEFAULT NULL COMMENT '时间',
    //   PRIMARY KEY (`id`)
    // ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COMMENT='站内信';

    //导入auto_message_text表
    public function importautomessagetext()
    {
      $sql = "CREATE TABLE IF NOT EXISTS `".$this->prefix."message_text` (
            `id` int(11) NOT NULL AUTO_INCREMENT,
            `title` varchar(255) DEFAULT NULL COMMENT '标题',
            `text` text COMMENT '内容',
            `addtime` int(11) DEFAULT NULL COMMENT '时间',
            PRIMARY KEY (`id`)
          ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COMMENT='站内信';";
        Db::execute($sql);
    }
    // CREATE TABLE IF NOT EXISTS `auto_sysmessage` (
    //   `id` int(11) NOT NULL AUTO_INCREMENT,
    //   `uid` varchar(255) DEFAULT NULL COMMENT '用户标识',
    //   `textid` int(11) DEFAULT '0' COMMENT '消息id',
    //   `sysstatus` int(11) DEFAULT '0' COMMENT '系统消息 已读1/未读0',
    //   PRIMARY KEY (`id`)
    // ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

    //导入auto_sysmessage表
    public function importautosysmessage()
    {
      $sql = "CREATE TABLE IF NOT EXISTS `".$this->prefix."sysmessage` (
            `id` int(11) NOT NULL AUTO_INCREMENT,
            `uid` varchar(255) DEFAULT NULL COMMENT '用户标识',
            `textid` int(11) DEFAULT '0' COMMENT '消息id',
            `sysstatus` int(11) DEFAULT '0' COMMENT '系统消息 已读1/未读0',
            PRIMARY KEY (`id`)
          ) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
        Db::execute($sql);
    }
    
}
